home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
shareware
/
fractals
/
apfelkiste
/
apfelkiste1.3
/
source
/
apfelkiste1.3src.lzh
/
Apfelkiste.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-30
|
24KB
|
880 lines
/************************************************************************/
/* Apfel.c --- Generates an image of the Mandelbrot-set */
/* */
/* Author: M. Böhnisch (BillySoft) */
/* Löher Str. 2 */
/* D-4790 Paderborn */
/* */
/* billy@uni-paderborn.de.pbinfo */
/*======================================================================*/
/* 06.11.89 iterative version with fixed box sizes (10 by 10), */
/* adapted a GFA-BASIC program from a german magazine */
/* */
/* 08.11.89 complete own version with recursive algorithm */
/* (divide & conquer) */
/* */
/* 10.11.89 added user input of picture size and borders */
/* */
/* 11.11.89 minor bug fixing */
/* */
/* 20.11.89 added fix-point arithmetik written in assembler */
/* format: */
/* */
/* [sgn|xxx xxxx xxxx xxxx.xxxx xxxx xxxx xxxx] */
/* */
/* not accurate enough. */
/* */
/* 21.11.89 rewrote fix-point format to: */
/* */
/* [sgn|xxx xxxx.xxxx xxxx xxxx xxxx xxxx xxxx] */
/* */
/* nice! (I'll try to use 26 bit after the point sometime) */
/* */
/* 28.11.89 found IFF-Library on Fish #173. save picture option */
/* added. */
/* */
/* 04.12.89 improved assembly program */
/* */
/* 07.12.89 slight optimization in recursion scheme */
/* */
/* 09.12.89 added input requester */
/* */
/* 21.07.90 review for Aztek-C5.0a */
/* */
/* 23.09.90 print option added (color printers) */
/* */
/* 25.09.90 added color requester */
/* */
/* 27.09.90 optimization of assembly program */
/* */
/* 15.11.90 review for Lattice-C5.10 */
/* */
/* 19.11.90 added a little retrying in case of an error by closing */
/* screens. Might recover some problems with Amigas short */
/* on memory or when really *BIG* screens are requested. */
/* */
/* 25.11.90 added s'more source code comments and translated all */
/* strings from german to english */
/* */
/* 30.01.91 removed a bug causing to save no colormap along with a */
/* picture */
/* */
/* 01.02.91 removed a bug making strange things while colorcycling */
/* pictures with more than 5 BitPlanes */
/* */
/* 01.02.91 added configuration facilities */
/* */
/* 17.04.91 removed a bug preventing the "Multitasking OFF" to work */
/* */
/* 18.04.91 some cast - operators added in "printersupport.h" to */
/* compile without warnings for Kick 2.0 */
/* */
/* 08.05.91 added 68030/68881 support */
/* */
/* 09.05.91 replaced lattice fp by fast floating point functions */
/************************************************************************/
/* -------------------------------------------------------------------- */
/* Some defininitions to take advantage of Lattice's LSR-code: */
/* -------------------------------------------------------------------- */
long _stack = 20000; /* Stack space for this task */
char *_procname = "Apfelkiste"; /* Name of process created */
long _priority = 0; /* Process priority */
long _BackgroundIO = 0; /* No stdio required */
/* -------------------------------------------------------------------- */
#define APFEL_VERSION "27"
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <graphics/gfx.h>
#include <graphics/gfxmacros.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <libraries/iff.h>
#include <libraries/arpbase.h>
#include <libraries/color.h>
#include <printersupport.h>
#include <clib/macros.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include <mffp.h>
#include <math.h>
#include "Apf0.h"
#include "Apf1.h"
#include "Apf2.h"
/* -------------------------------------------------------------------- */
/* Prototypes for the functions in the other modules */
/* -------------------------------------------------------------------- */
void FixPoint(double rmin, double rmax, double imin, double imax, double dx, double dy,
int maxiter, double divergenz, int gx, int gy, int depth);
void __regargs Apfel_Alert(long number);
void __regargs Activate_Gadget(struct Window *w, USHORT ID);
void __regargs Apfel_FLOAT(int x1, int y1, int x2, int y2);
long Iter_FLOAT(double r, double i);
/* --------------------------------------------------------------------- */
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct IFFBase *IFFBase;
struct ArpBase *ArpBase;
struct ColorBase *ColorBase;
struct Screen *s;
struct Window *w, *u, *v;
struct RastPort *rp, *up;
struct ViewPort *vp;
short cycle, task = TRUE;
APTR IFFfile = NULL;
struct FileRequester *FReq;
union printerIO *request;
struct MsgPort *printerPort;
int gx, gy, xsize, ysize, depth, hide;
short maxcol;
int maxiter;
double divergenz, rmin, rmax, imin, imax, dx, dy;
/* -------------------------------------------------------------------- */
/* All the stuff needed to comfortably get IntuitionMessages */
/* -------------------------------------------------------------------- */
#define GAD_ID (((struct Gadget *)ADDR)->GadgetID)
ULONG CLASS, CODE;
APTR ADDR;
struct IntuiMessage *Message = NULL;
ULONG GetMessage(struct Window *MW)
{
CLASS = CODE = 0;
ADDR = NULL;
if ( Message = (struct IntuiMessage *) GetMsg(MW->UserPort) ) {
CLASS = Message->Class;
CODE = Message->Code;
ADDR = Message->IAddress;
ReplyMsg((struct Message *) Message);
}
return(CLASS);
}
/* -------------------------------------------------------------------- */
/* Simple routine to draw a rectangular shape. Used for the Mouse Opt */
/* -------------------------------------------------------------------- */
void DrawRect(struct RastPort *rp, short x1, short y1, short x2, short y2)
{
Move(rp, x1, y1);
Draw(rp, x2, y1);
Draw(rp, x2, y2);
Draw(rp, x1, y2);
Draw(rp, x1, y1);
}
/* -------------------------------------------------------------------- */
/* Pre-initialized structures for main screen and window */
/* -------------------------------------------------------------------- */
struct NewScreen NS = {
0, 0, /* screen XY origin relative to View */
0, 0, /* screen width and height */
0, /* screen depth (number of bitplanes) */
0, 1, /* detail and block pens */
NULL, /* display modes for this screen */
CUSTOMSCREEN | SCREENQUIET, /* screen type */
NULL, /* pointer to default screen font */
NULL, /* screen title */
NULL, /* first in list of custom screen gadgets */
NULL /* pointer to custom BitMap structure */
};
struct NewWindow NW = {
0, 0, /* window XY origin relative to TopLeft of screen */
0, 0, /* window width and height */
0, 1, /* detail and block pens */
NULL, /* IDCMP flags */
SMART_REFRESH |
ACTIVATE |
BORDERLESS, /* other window flags */
NULL, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
NULL, /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5, 5, /* minimum width and height */
-1, -1, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
/* -------------------------------------------------------------------- */
/* Default palette. Change this if you don't like the colors provided */
/* by me. Versions 25 and higher are supporting a custom default file. */
/* -------------------------------------------------------------------- */
USHORT Palette[128] = {
0x0000, /* color #0 */
0x0F90, /* color #1 */
0x0F20, /* color #2 */
0x0840, /* color #3 */
0x0580, /* color #4 */
0x0589, /* color #5 */
0x055F, /* color #6 */
0x0A0F, /* color #7 */
0x0F08, /* color #8 */
0x0777, /* color #9 */
0x0080, /* color #10 */
0x00A0, /* color #11 */
0x00C0, /* color #12 */
0x00E0, /* color #13 */
0x08E0, /* color #14 */
0x0FF0, /* color #15 */
0x0000, /* color #16 */
0x0F90, /* color #17 */
0x0F20, /* color #18 */
0x0840, /* color #19 */
0x0580, /*